<script language="javascript" type="text/javascript" charset="utf-8">
var oTable;
var dialog;
function redraw(){
    oTable.fnDraw();
}

function reset_filters(){
    $("#part_num").val("");
    $("#upc").val("");
    $("#prod_name").val("");
    redraw();
}
function showMore(id){
    txt =  $("#"+id).html();
    $("#dialog_p").html(txt);
    dialog.dialog('open');

}
function init_dialog(){
    dialog =  $( "#dialog" ).dialog(
    {
        autoOpen: false ,
        width: 800,
        height:500,
        modal:true
    });
}

$(document).ready(function() {

        oTable = $('#table').dataTable({
        "aoColumns": [
            null,
            null,
            null,
            null,
            null,
            {"sClass":"left"}
            ],

        "bFilter": true,
        "bPaginate": true,
        "fnDrawCallback" : function(){
        },
        "sPaginationType": "full_numbers",
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "{{$base_index_url}}/product/admin/search/table",
        "fnServerData": function ( sSource, aoData, fnCallback ) {
                //REQUIRED: Add a Post variable with the object value
                aoData.push( { "name": "part_num","value": $("#part_num").val()});
                aoData.push( { "name": "prod_name","value": $("#prod_name").val()});
                aoData.push( { "name": "upc","value": $("#upc").val()});
                $.ajax({
                            "dataType": 'json',
                            "type": "POST",
                            "url": sSource,
                            "data":aoData,
                            "error": function(){
                                    alert('Error!!!!!!!');
                            },
                            "success":  fnCallback
                    });
        }
    });
} );

</script>

        <fieldset>
            <legend>Search Product</legend>
            <table>
<!--                <tr>
                    <td>Part Number :</td>
                    <td><input type="text" id="part_num" onkeypress="if(event.keyCode==13) redraw();" /> </td>
                </tr>-->
                <tr>
                    <td>Product Name :</td>
                    <td><input type="text" id="prod_name" onkeypress="if(event.keyCode==13) redraw();" /> </td>
                </tr>
                <tr>
                    <td>UPC :</td>
                    <td><input type="text" id="upc" onkeypress="if(event.keyCode==13) redraw();" /> </td>
                </tr>
                <tr>
                    <td align="left">
                        <input type="button" onclick="redraw()" value="Search"  />
                    </td>
                    <td align="left">
                        <input type="button" onclick="reset_filters()" value="Reset"  />
                    </td>
                </tr>
            </table>
        </fieldset>
            
        <fieldset>
            <table class="display" width="100%" id="table">
                <thead>
                     <tr>
                         <th>Short Description</th>
                         <th>UPC</th>
                         <th>Price</th>
                         <th>Publish</th>
                         <th>Category</th>
                         <th>Action</th>
                     </tr>
                </thead>
                <tbody></tbody>
            </table>
        </fieldset>
